﻿using System;
using CSRedis;
using JT809.RedisService.Configs;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace JT809.RedisService
{
    public static class JT809RedisServiceExtensions
    {
        public static IServiceCollection AddJT809RedisPushService(this IServiceCollection serviceDescriptors, IConfiguration configuration)
        {
            serviceDescriptors.Configure<JT809RedisConfig>(configuration.GetSection("JT809RedisConfig"));
            serviceDescriptors.AddSingleton(provider =>
            {
                return new CSRedisClient(configuration.GetSection("JT809RedisConfig:Connection").Value);
            });
            serviceDescriptors.AddSingleton<JT809_GpsPostion_Psuh>();
            return serviceDescriptors;
        }


        //public static IServiceCollection AddJT809KafkaConsumerService(this IServiceCollection serviceDescriptors, IConfiguration configuration)
        //{
        //    serviceDescriptors.Configure<JT809ConsumerConfig>(configuration.GetSection("JT809ConsumerConfig"));
        //    serviceDescriptors.AddSingleton<JT809_GpsPosition_Consumer>();
        //    return serviceDescriptors;
        //}
    }
}
